def getprimes(limit):
    primes = []
    numbers = [True] * limit

    for i in range(2, limit):
        # если число простое
        if numbers[i]:
            primes.append(i)
            for j in range(i ** 2, limit, i):
                numbers[j] = False
    return primes


def text2int(sent):
    words = sent.split()
    units = {"zero": '0', "one": '1', "two": '2',
             "three": '3', "four": '4', "five": '5',
             "six": '6', "seven": '7', "eight": '8',
             "nine": '9'}

    if len(words) < 3:
        return 'Wrong input'
    for i in range(len(words)):
        for j in range(len(units)):
            if words[i] not in units.keys():
                return 'Wrong input'
    result = int(''.join(units[e] for e in sent.split()))
    return result


n = text2int(input())
if str(n).isnumeric() is True:
    primes = getprimes(n + 100)
    maxDist = 99999999
    numb = 0

    for p in primes:
        if abs(n - p) < maxDist:
            maxDist = abs(n - p)
            numb = p
    print(numb)
else:
    print(n)
